import random

ran = random.random()  # 生成0-1之间的随机小数
print(ran)

ran = random.randrange(1,10,2)  # 生成1-10之间的随机整数,步长为2 randrange(start,stop,step)
print(ran)

ran = random.randint(1,10)  # 生成1-10之间的随机整数 [ , ]
print(ran)

list1 = ['张三','李四','王五','赵六','钱七']
ran = random.choice(list1) # 随机选择列表中的元素
print(ran)

pai = ['红桃A','方块K','梅花2','黑桃J']
random.shuffle(pai) # 打乱列表
print(pai)

def func():
    code = ''
    for i in range(4):
        ran1 = str(random.randint(0,9))
        ran2 = chr(random.randint(65,90))
        ran3 = chr(random.randint(97,122))

        r = random.choice([ran1,ran2,ran3])
        code += r
    return code

code = func()
print(code)


